home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 424_02 / ED-157 / right_arrow.c < prev    next >
C/C++ Source or Header  |  1994-02-08  |  2KB  |  77 lines

  1. /*
  2.  * Copyright (C) 1992 by Rush Record
  3.  * Copyright (C) 1993 by Charles Sandmann (sandmann@clio.rice.edu)
  4.  * 
  5.  * This file is part of ED.
  6.  * 
  7.  * ED is free software; you can redistribute it and/or modify it under the terms
  8.  * of the GNU General Public License as published by the Free Software Foundation.
  9.  * 
  10.  * ED is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  11.  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  12.  * PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  13.  * 
  14.  * You should have received a copy of the GNU General Public License along with ED
  15.  * (see the file COPYING).  If not, write to the Free Software Foundation, 675
  16.  * Mass Ave, Cambridge, MA 02139, USA.
  17.  */
  18. #include "opsys.h"
  19.  
  20. #include "rec.h"
  21. #include "window.h"
  22. #include "ed_dec.h"
  23.  
  24. /******************************************************************************\
  25. |Routine: right_arrow
  26. |Callby: edit insert wincom word_fill
  27. |Purpose: Does what is required to move the cursor to the right. If the cursor
  28. |         is at the end of a record, moves it to the beginning of the following
  29. |         record.
  30. |Arguments:
  31. |    repeat is the repeat count for the action.
  32. \******************************************************************************/
  33. void right_arrow(repeat)
  34. register Int repeat;
  35. {
  36.     Int i;
  37.     register Int ch,c;
  38.     register Char *p;
  39.  
  40.     i = repeat;
  41.     while(CURREC->length - CURBYT < i)
  42.     {
  43.         if(CURREC == BASE)
  44.         {
  45.             i = 0;
  46.             abort_key();
  47.             break;
  48.         }
  49.         i -= CURREC->length - CURBYT + 1;
  50.         CURBYT = 0;
  51.         CURREC = CURREC->next;
  52.         CURROW++;
  53.         CURCOL = 1;
  54.     }
  55.     if(HEXMODE)
  56.     {
  57.         CURCOL += (i << 2);
  58.         CURBYT += i;
  59.     }
  60.     else
  61.     {
  62.         for(c = CURCOL - 1,p = CURREC->data + CURBYT;i--;p++,CURBYT++)
  63.         {
  64.             if((ch = *p) == '\t')
  65.                 c = tabstop(c);
  66.             else if(NONPRINTNCS(ch))
  67.                 c += 4;
  68.             else
  69.                 c++;
  70.         }
  71.         CURCOL = ++c;
  72.     }
  73.     WANTCOL = CURCOL;
  74.     fix_display();
  75. }
  76.  
  77.